//
//  MyUser.swift
//  weibo08
//
//  Created by 陈杰明 on 16/3/5.
//  Copyright © 2016年 JM. All rights reserved.
//

import UIKit

class MyUser: NSObject {

    /// 用户UID
    var id: Int = 0
    
    /// 友好显示名称
    var name: String?
    
    /// 用户头像地址（中图），50×50像素
    var profile_image_url: String?
    
    /// 是否是微博认证用户，即加V用户，true：是，false：否
    var verified: Bool = false
    
    /// verified_type 没有认证:-1   认证用户:0  企业认证:2,3,5  达人:220
    var verified_type: Int = -1 {
        didSet{
            
            switch verified_type {
            case 0:
                verifiedTypeImage = UIImage(named: "avatar_vip")
            case 2,3,5:
                verifiedTypeImage = UIImage(named: "avatar_enterprise_vip")
            case 220:
                verifiedTypeImage = UIImage(named: "avatar_grassroot")
            default :
                verifiedTypeImage = nil
            }
        }
    }
    
    /// 会员等级 1-6
    var mbrank: Int = 0 {
        didSet{
            if mbrank > 0 && mbrank <= 6 {
                mbImage = UIImage(named: "common_icon_membership_level\(mbrank)")
            }else{
                mbImage = nil
            }
        
        }
    
    }
    //会员图片
    var mbImage: UIImage?
    //认证图片
    var verifiedTypeImage: UIImage?
    
    init(dict: [String : AnyObject]) {
        super.init()
        
        setValuesForKeysWithDictionary(dict)
    }

    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
    
    override var description: String {
        let keys = ["id", "name", "profile_image_url", "verified", "verified_type", "mbrank",]
        
        return "\n\t用户模型:\(dictionaryWithValuesForKeys(keys).description)"
        
    }
}
